/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import contractmessageservice.ContractMessage;
import electricitysupplier.ContractMessage.ClientParty;
import electricitysupplier.ContractMessage.ContractInfo;
import electricitysupplier.PartyType;

/**
 *
 * @author Yuuzaa
 */
public class ContractMessageConverter {

    public static electricitysupplier.ContractMessage convertContract(ContractMessage cm) {
        electricitysupplier.ContractMessage ecm = new electricitysupplier.ContractMessage();
        electricitysupplier.ContractMessage.ClientParty escp = new ClientParty();
        electricitysupplier.ContractMessage.ContractInfo esci = new ContractInfo();
        electricitysupplier.PartyType espt = new PartyType();
        espt.setAddress(cm.getProviderParty().getAddress());
        espt.setContactEmail(cm.getProviderParty().getContactEmail());
        espt.setContactPhone(cm.getProviderParty().getContactPhone());
        espt.setName(cm.getProviderParty().getName());
        espt.setRegistryCode(cm.getProviderParty().getRegistryCode());
        escp.setAreaId(cm.getClientParty().getAreaId());
        escp.setContactEmail(cm.getClientParty().getContactEmail());
        escp.setContactPhone(cm.getClientParty().getContactPhone());
        escp.setFacilityId(cm.getClientParty().getFacilityId());
        escp.setName(cm.getClientParty().getName());
        escp.setRegistryCode(cm.getClientParty().getRegistryCode());
        esci.setContractId(cm.getContractInfo().getContractId());
        esci.setEndDate(cm.getContractInfo().getEndDate());
        esci.setStartDate(cm.getContractInfo().getStartDate());
        ecm.setClientParty(escp);
        ecm.setConfirmed(cm.isConfirmed());
        ecm.setContractInfo(esci);
        ecm.setMessage(cm.getMessage());
        ecm.setMessageId(cm.getMessageId());
        ecm.setMessageRecieverParty(cm.getMessageRecieverParty());
        ecm.setMessageSenderParty(cm.getMessageSenderParty());
        ecm.setProviderParty(espt);
        ecm.setRelatedMessageId(cm.getRelatedMessageId());
        return ecm;
    }
}
